package com.example.springai.service.impl;

import com.example.springai.service.RagService;
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.document.Document;
import org.springframework.ai.reader.JsonReader;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.util.List;

@Service
public class RagServiceImpl implements RagService {

    private final Logger logger = LoggerFactory.getLogger(RagServiceImpl.class);

    private final VectorStore vectorStore;

    public RagServiceImpl(VectorStore vectorStore) {
        this.vectorStore = vectorStore;
    }

    @Override
    public void load(String txt) {
        if (logger.isInfoEnabled()) {
            logger.info("Loading Rag Txt: {}", txt);
        }
        Document document = new Document(txt);
        vectorStore.add(List.of(document));
    }

    @Override
    public void load(File sourceFile) {

    }

    @Override
    public void load(MultipartFile sourceFile) {

    }
}
